package com.example.Rim.View;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
<<<<<<< HEAD
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;
import com.example.Rim.R;

import java.util.ArrayList;
import java.util.List;
=======
import android.view.View;
import android.view.Window;
import android.widget.Button;
import com.example.Rim.R;

import java.lang.Override;
>>>>>>> fef9999bb02b62b3a5652ba7b6339bc4bd51442a

public class ActivityMain extends Activity {
    /**
     * Called when the activity is first created.
     */
<<<<<<< HEAD

    private ListView mainListView;
    private boolean flag = true;
    private Button tosearchButton;
    private Button toaboutButton;

=======
    private Button mainSearchButton;
>>>>>>> fef9999bb02b62b3a5652ba7b6339bc4bd51442a
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_main);
<<<<<<< HEAD

        mainListView = (ListView) findViewById(R.id.mainListView);
        mainListView.setAdapter(new Mydapter());

        toaboutButton = (Button) findViewById(R.id.toaboutButton);
        toaboutButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(ActivityMain.this,ActivityAbout.class);
                startActivity(intent);
            }
        });

        tosearchButton = (Button) findViewById(R.id.tosearchButton);
        tosearchButton.setOnClickListener(new View.OnClickListener() {
=======
        mainSearchButton = (Button)findViewById(R.id.mainSearchButton);
        mainSearchButton.setOnClickListener(new View.OnClickListener() {
>>>>>>> fef9999bb02b62b3a5652ba7b6339bc4bd51442a
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(ActivityMain.this,ActivitySearch.class);
                startActivity(intent);
            }
        });
    }
   class Mydapter extends BaseAdapter{
       final String[] list={"餐饮服务","购物服务","生活服务","体育休闲服务","医疗保健服务","住宿服务","科教文化服务","交通设施服务"};
       @Override
       public int getCount() {
           return list.length;
       }

       @Override
       public Object getItem(int position) {
           return list[position];
       }

       @Override
       public long getItemId(int position) {
           return position;
       }

       @Override
       public View getView(int position, View convertView, ViewGroup parent) {
           View view= LayoutInflater.from(ActivityMain.this).inflate(R.layout.list_menu, parent, false);
           TextView list_textView= (TextView) view.findViewById(R.id.listTextView);
           list_textView.setText(list[position]);

           final String list_text =  list_textView.getText().toString();
           Button listButton = (Button) view.findViewById(R.id.listButton);
           listButton.setOnClickListener(new View.OnClickListener() {
               @Override
               public void onClick(View v) {
                   Intent intent = new Intent(ActivityMain.this,ActivitySecond.class);
                   intent.putExtra("flag",flag);
                   intent.putExtra("list_text",list_text);
                   startActivity(intent);
               }
           });
           return view;
       }
   }
}

